﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartSpace.Core;
using SmartSpace.Data;

namespace SsTool.Common
{
    /// <summary>
    /// Interaction logic for SelectEntityMetadataWindow.xaml
    /// </summary>
    public partial class SelectEntityMetadataWindow : Window
    {
        public EntityMetadata SelectedEntity { get; private set; }

        public SelectEntityMetadataWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SelectEntityMetadataWindow_Loaded);
        }

        void SelectEntityMetadataWindow_Loaded(object sender, RoutedEventArgs e)
        {
            IDataService service = App.Get<IDataService>();
            _ctlGrid.ItemsSource = service.FindEntities(0, 999);
        }

        private void _ctlBtnSelect_Click(object sender, RoutedEventArgs e)
        {
            SelectedEntity = _ctlGrid.SelectedItem as EntityMetadata;
            if (SelectedEntity != null)
            {
                DialogResult = true;
            }
        }
    }
}
